package com.linkoog.devtools.json.action;

import com.intellij.json.JsonFileType;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
import com.intellij.testFramework.LightVirtualFile;
import com.linkoog.devtools.json.JsonEditerCricleNumber;
import org.jetbrains.annotations.NotNull;


public class OpenJsonEditerAction extends AnAction {

    @Override
    public void actionPerformed(@NotNull AnActionEvent e) {
        Project project = e.getProject();
        if (project == null) return;

        String name = "temp-" +  JsonEditerCricleNumber.nextNumber() + ".json";
        LightVirtualFile lightVirtualFile = new LightVirtualFile(name, JsonFileType.INSTANCE, "");
        FileEditorManager.getInstance(project).openFile(lightVirtualFile, true);
    }





}
